<%@ page language="java"  pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="<%=path %>/styles/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=path %>/js/main.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery.form.js"></script>
</head>
<body>
<form id="groupForm" name="groupForm"  method="post" action="<%=path %>/system/group/save.do"> 
<div id="DetailContent">	
	<table width="100%" border="0" cellspacing="2" cellpadding="2"  class="TableForm">
	  <tr>
		<td  nowrap="nowrap" width="80">组名称：</td>
		 <td class="NTbsM">
		 	<input name="groupId" type="hidden" value='<s:property value="group.groupId"/>'/>
		 	<input name="groupName" type="text" value='<s:property value="group.groupName"/>' class="InputText" onfocus="this.className='InputTextDown'" onblur="this.className='InputText'" />
		 </td>
	  </tr>
	  <tr>
		<td>组描述：</td>
		<td><textarea name="groupDesc" rows="3" class="InputText" onfocus="this.className='InputTextDown'" onblur="this.className='InputText'" style="width:100%" ><s:property value="group.groupDesc"/></textarea></td>
	  </tr>	  
	</table>
	<!--角色权限-->
	<fieldset style="-moz-border-radius:8px;">
		<legend>选择组成员</legend>
		<table width="100%" border="0" cellspacing="0" cellpadding="0"  align="center"  >
			<tr>
				<td width="220" height="30">
					<select id="deptId" name="deptId" class="DropDown" onchange="getUserList(this)">
					  <option value="">——请选择——</option>
					  <s:iterator value="deptList">
							<option value="<s:property value="orgId"/>"><s:property value="orgName"/></option>
					  </s:iterator> 
					 </select>
				</td>
				<td widht="60"></td>
				<td width="220"></td>
			</tr>			
			<tr>
			    <td>		    	
			    	<select id="allUser" name="allUser" multiple="true"  class="multi_Select"></select>
				</td>
				<td  align="center" >
					<input name="btnMoveRight" type="button" class="arrowRGo" onClick="moveSelected(document.getElementById('allUser'),document.getElementById('selUser'))" /><br /><br />
					<input name="btnMoveLeft" type="button" class="arrowLGo" onClick="moveSelected(document.getElementById('selUser'),document.getElementById('allUser'))" />  
				</td>	
				<td><input type="hidden" name="selUsers" id="selUsers"/>
					<select id="selUser" name="selUser" multiple="true" class="multi_Select">
					   <s:iterator value="groupUserList">
							<option value="<s:property value="userId"/>"><s:property value="empName"/></option>
					   </s:iterator> 
					 </select>
				</td>
			 </tr>
        </table>
	</fieldset>
	
</div>  
<!--工具按钮-->
<div  id="FormToobar" style="margin:0 5px; border: solid 1px #6d6d6d;">
	<div id="MsgDiv" style="float:left"></div>
	<div style="float:right">
	    <tt><input name="保存23" type="button" class="But" value="保存" onclick="save()"/> </tt>
	    <tt><input name="返回23" type="button" class="But" value="返回" onclick="parent.ymPrompt.close();" /></tt>
    </div>	
</div>
</form>
<script type="text/javascript">
	function save(){		
		var selUsers="";
		var selUserObj=document.getElementById('selUser');
		for(var i=0;i<selUserObj.options.length;i++){
			selUsers = selUsers+","+selUserObj.options[i].value;			
		}
		document.getElementById("selUsers").value=selUsers;
		
	    var form = $("form[name=groupForm]"); 
        var options = {success:showResponse,resetForm:false,dataType:'script'};
        form.ajaxSubmit(options);       
        return;   
	}
	function showResponse(data){//回调函数
	    if(1 == data){
	    	document.getElementById("MsgDiv").innerHTML="保存成功！";
	    	parent.loadPage();	     
	    }else{
	        document.getElementById("MsgDiv").innerHTMNL="操作失败";
	    }
	}
	function getUserList(obj){
		var deptId=obj.value;		
		$('#allUser').empty();
		var selectContainer = $('#allUser');
		$.getJSON("<%=path%>/system/user/getUserList.do?deptId="+deptId, function(data){
	  		$.each(data.list, function(i,item){	  			
	  			var option = $('<option></option>').text(item.empName).val(item.userId);
	  			selectContainer.append(option);	    	
	  		});
		});
	}
	function getSelectedOption(){
		var options = $('#allUser > option:selected');
		$.each(options, function () {
			alert('option: ' + this.value);
		});	
	}
</script>
</body>
</html>
